package Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class BrandList {
    private String[]card={"♥","♠","♣","♦"};
public List<Brand> BuyBrand(){
    List<Brand>list=new ArrayList<>();
    for (int i = 0; i <13 ; i++) {
        for (int j = 0; j <4 ; j++) {
            Brand brand=new Brand(i+1,card[j]);
            list.add(brand);
        }
    }
return list;
}

public void shuffle(List<Brand>brands){
    Random random=new Random();
    for (int i = 0; i <52 ; i++) {
        int x= random.nextInt(52);
swap(brands,i,x);
    }
}

private void swap(List<Brand>brands,int x,int pos){
Brand brand=brands.get(x);
brands.set(x,brands.get(pos));
brands.set(pos,brand);
}


public List<List<Brand>>play(List<Brand>brands){
    List<Brand>hand1=new ArrayList<>();
    List<Brand>hand2=new ArrayList<>();
    List<Brand>hand3=new ArrayList<>();
    List<List<Brand>> brand=new ArrayList<>();
brand.add(hand1);
brand.add(hand2);
brand.add(hand3);
    for (int i = 0; i <5 ; i++) {
        for (int j = 0; j <3 ; j++) {
            brand.get(j).add(brands.remove(0));
        }
    }
return brand;

}



}
